<template>
  <div>

    <el-row>
      <el-col :span="2"><div>姓名：</div></el-col>
      <el-col :span="4"
        ><div>
          <el-input
            v-model="name"
            size="mini"
            placeholder="请输入内容"
          ></el-input></div
      ></el-col>
      <el-col :span="2"><div>部门：</div></el-col>
      <el-col :span="6"
        ><div>
          <el-select v-model="department" placeholder="请选择" size="mini">
            <el-option
              v-for="item in Department"
              :key="item.Id"
              :label="item.Department_Name"
              :value="item.Id"
            >
            </el-option>
          </el-select></div
      ></el-col>
      <el-col :span="2"><div>职位：</div></el-col>
      <el-col :span="6"
        ><div>
          <el-select v-model="position" placeholder="请选择" size="mini">
            <el-option
              v-for="item in Position"
              :key="item.Id"
              :label="item.Position_Name"
              :value="item.Id"
            >
            </el-option>
          </el-select></div
      ></el-col>
    </el-row>
    <el-row>
      <el-col :span="2"><div>手机号：</div></el-col>
      <el-col :span="4"
        ><div>
          <el-input
            v-model="phone"
            placeholder="请输入内容"
            size="mini"
          ></el-input></div
      ></el-col>
      <el-col :span="2"><div>类别：</div></el-col>
      <el-col :span="6"
        ><div>
          <el-select v-model="category" placeholder="请选择" size="mini">
            <el-option
              v-for="item in Category"
              :key="item.Id"
              :label="item.Dictionary_Name"
              :value="item.Id"
            >
            </el-option>
          </el-select></div
      ></el-col>
      <el-col :span="4"
        ><div>
          <el-button size="mini" type="primary" @click="GetShow">查询</el-button
          ><el-button size="mini" @click="Reset">重置</el-button>
        </div></el-col
      >
      <el-col :span="4"><div></div></el-col>
    </el-row>
    <el-row>
      <el-col :span="4"
        ><div>
          <el-button type="primary" @click="dialogFormVisible = true"
            >添加</el-button
          >
          <el-button type="primary" @click="DelEmployees">删除</el-button>
        </div></el-col
      >
    </el-row>
    <el-table
      :data="tableData"
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55"> </el-table-column>
      <el-table-column prop="Employees_Name" label="姓名" width="150">
      </el-table-column>
      <el-table-column label="性别" width="150">
        <template slot-scope="scope">
          {{ scope.row.EmployeesSex == true ? "男" : "女" }}
        </template>
      </el-table-column>
      <el-table-column prop="Department_Name" label="部门" width="150">
      </el-table-column>
      <el-table-column prop="Position_Name" label="职位" width="150">
      </el-table-column>
      <el-table-column prop="Employees_Phone" label="手机号" width="150">
      </el-table-column>
      <el-table-column prop="Employees_Universities" label="院校" width="150">
      </el-table-column>
      <el-table-column prop="Employees_Professional" label="专业" width="150">
      </el-table-column>
      <el-table-column prop="Employees_Address" label="家庭住址" width="150">
      </el-table-column>
      <el-table-column prop="Position_Name" label="类别" width="150">
        <template slot-scope="scope">
          {{ scope.row.Position_Name }}
        </template>
      </el-table-column>
      <el-table-column label="状态" width="150">
        <template slot-scope="scope">
          {{
            scope.row.Employees_State == 1
              ? "待入职"
              : scope.row.Employees_State == 2
              ? "试用期"
              : scope.row.Employees_State == 3
              ? "待转正"
              : scope.row.Employees_State == 4
              ? "已转正"
              : scope.row.Employees_State == 5
              ? "待离职"
              : "已离职"
          }}
        </template>
      </el-table-column>
      <el-table-column prop="Employees_DateTimes" label="创建时间" width="180">
      </el-table-column>
      <el-table-column label="操作" fixed="right" width="250">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.row)"
            >删除</el-button
          >
          <el-button size="mini" @click="handleEdits(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageindex"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalcount"
    >
    </el-pagination>

    <el-dialog title="新增员工" :visible.sync="dialogFormVisible">
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="姓名" prop="Employees_Name">
                <el-input
                  v-model="ruleForm.Employees_Name"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="性别" prop="EmployeesSex">
                <el-radio-group v-model="ruleForms.EmployeesSex">
                  <el-radio :label="true">男</el-radio>
                  <el-radio :label="false">女</el-radio>
                </el-radio-group>
              </el-form-item>
            </div></el-col
          >
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="手机号" prop="Employees_Phone">
                <el-input
                  v-model="ruleForm.Employees_Phone"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="院校" prop="Employees_Universities">
                <el-input
                  v-model="ruleForm.Employees_Universities"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="专业" prop="Employees_Professional">
                <el-input
                  v-model="ruleForm.Employees_Professional"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="家庭住址" prop="Employees_Address">
                <el-input
                  v-model="ruleForm.Employees_Address"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="学历" prop="Employees_EducationBackground">
                <el-select
                  v-model="ruleForm.Employees_EducationBackground"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in EducationBackground"
                    :key="item.Id"
                    :label="item.Dictionary_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item
                label="政治面貌"
                prop="Employees_PoliticalLandscape"
              >
                <el-input
                  v-model="ruleForm.Employees_PoliticalLandscape"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="民族" prop="Employees_National">
                <el-input
                  v-model="ruleForm.Employees_National"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="籍贯" prop="Employees_NativePlace">
                <el-input
                  v-model="ruleForm.Employees_NativePlace"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="婚姻" prop="Employees_Marriage">
                <el-select
                  v-model="ruleForm.Employees_Marriage"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in Marriage"
                    :key="item.Id"
                    :label="item.Dictionary_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="出生年月" prop="Employees_DateBirth">
                <el-date-picker
                  v-model="ruleForm.Employees_DateBirth"
                  type="date"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="邮箱" prop="Employees_Email">
                <el-input
                  v-model="ruleForm.Employees_Email"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="身份证" prop="Employees_IdCard">
                <el-input
                  v-model="ruleForm.Employees_IdCard"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="部门" prop="Department_Id">
                <el-select
                  v-model="ruleForm.Department_Id"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in Department"
                    :key="item.Id"
                    :label="item.Department_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="职位" prop="Position_Id">
                <el-select v-model="ruleForm.Position_Id" placeholder="请选择">
                  <el-option
                    v-for="item in Position"
                    :key="item.Id"
                    :label="item.Position_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="员工类别" prop="Employees_Category">
                <el-select
                  v-model="ruleForm.Employees_Category"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in Category"
                    :key="item.Id"
                    :label="item.Dictionary_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"><div></div></el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitForm('ruleForm')"
          >确 定</el-button
        >
      </div>
    </el-dialog>

    <el-dialog title="修改员工" :visible.sync="dialogFormVisibles">
      <el-form
        :model="ruleForms"
        :rules="rules"
        ref="ruleForms"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="姓名" prop="Employees_Name">
                <el-input
                  v-model="ruleForms.Employees_Name"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="性别" prop="EmployeesSex">
                <el-radio-group v-model="ruleForms.EmployeesSex">
                  <el-radio :label="true">男</el-radio>
                  <el-radio :label="false">女</el-radio>
                </el-radio-group>
              </el-form-item>
            </div></el-col
          >
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="手机号" prop="Employees_Phone">
                <el-input
                  v-model="ruleForms.Employees_Phone"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="院校" prop="Employees_Universities">
                <el-input
                  v-model="ruleForms.Employees_Universities"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="专业" prop="Employees_Professional">
                <el-input
                  v-model="ruleForms.Employees_Professional"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="家庭住址" prop="Employees_Address">
                <el-input
                  v-model="ruleForms.Employees_Address"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="学历" prop="Employees_EducationBackground">
                <el-select
                  v-model="ruleForms.Employees_EducationBackground"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in EducationBackground"
                    :key="item.Id"
                    :label="item.Dictionary_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item
                label="政治面貌"
                prop="Employees_PoliticalLandscape"
              >
                <el-input
                  v-model="ruleForms.Employees_PoliticalLandscape"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="民族" prop="Employees_National">
                <el-input
                  v-model="ruleForms.Employees_National"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="籍贯" prop="Employees_NativePlace">
                <el-input
                  v-model="ruleForms.Employees_NativePlace"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="婚姻" prop="Employees_Marriage">
                <el-select
                  v-model="ruleForms.Employees_Marriage"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in Marriage"
                    :key="item.Id"
                    :label="item.Dictionary_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="出生年月" prop="Employees_DateBirth">
                <el-date-picker
                  v-model="ruleForms.Employees_DateBirth"
                  type="date"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="邮箱" prop="Employees_Email">
                <el-input
                  v-model="ruleForms.Employees_Email"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="身份证" prop="Employees_IdCard">
                <el-input
                  v-model="ruleForms.Employees_IdCard"
                  placeholder="请输入内容"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="部门" prop="Department_Id">
                <el-select
                  v-model="ruleForms.Department_Id"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in Department"
                    :key="item.Id"
                    :label="item.Department_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="职位" prop="Position_Id">
                <el-select v-model="ruleForms.Position_Id" placeholder="请选择">
                  <el-option
                    v-for="item in Position"
                    :key="item.Id"
                    :label="item.Position_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="员工类别" prop="Employees_Category">
                <el-select
                  v-model="ruleForms.Employees_Category"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in Category"
                    :key="item.Id"
                    :label="item.Dictionary_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"><div></div></el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisibles = false">取 消</el-button>
        <el-button type="primary" @click="submitForms('ruleForms')"
          >确 定</el-button
        >
      </div>
    </el-dialog>
    <el-dialog title="修改员工" :visible.sync="dialogFormVisibless">
      <el-form
        :model="ruleForms"
        :rules="rules"
        ref="ruleForms"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="姓名" prop="Employees_Name">
                <el-input
                  v-model="ruleForms.Employees_Name"
                  placeholder="请输入内容"
                  readonly="readonly"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="性别" prop="EmployeesSex" readonly="readonly">
                <el-radio-group v-model="ruleForms.EmployeesSex" disabled>
                  <el-radio :label="true">男</el-radio>
                  <el-radio :label="false">女</el-radio>
                </el-radio-group>
              </el-form-item>
            </div></el-col
          >
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="手机号" prop="Employees_Phone">
                <el-input
                  v-model="ruleForms.Employees_Phone"
                  placeholder="请输入内容"
                  readonly="readonly"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="院校" prop="Employees_Universities">
                <el-input
                  v-model="ruleForms.Employees_Universities"
                  placeholder="请输入内容"
                  readonly="readonly"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="专业" prop="Employees_Professional">
                <el-input
                  v-model="ruleForms.Employees_Professional"
                  placeholder="请输入内容"
                  readonly="readonly"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="家庭住址" prop="Employees_Address">
                <el-input
                  v-model="ruleForms.Employees_Address"
                  placeholder="请输入内容"
                  readonly="readonly"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="学历" prop="Employees_EducationBackground">
                <el-select
                  v-model="ruleForms.Employees_EducationBackground"
                  placeholder="请选择"
                  disabled
                >
                  <el-option
                    v-for="item in EducationBackground"
                    :key="item.Id"
                    :label="item.Dictionary_Name"
                    :value="item.Id"
                    disabled
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item
                label="政治面貌"
                prop="Employees_PoliticalLandscape"
              >
                <el-input
                  v-model="ruleForms.Employees_PoliticalLandscape"
                  placeholder="请输入内容"
                  readonly="readonly"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="民族" prop="Employees_National">
                <el-input
                  v-model="ruleForms.Employees_National"
                  placeholder="请输入内容"
                  readonly="readonly"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="籍贯" prop="Employees_NativePlace">
                <el-input
                  v-model="ruleForms.Employees_NativePlace"
                  placeholder="请输入内容"
                  readonly="readonly"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="婚姻" prop="Employees_Marriage">
                <el-select
                  v-model="ruleForms.Employees_Marriage"
                  placeholder="请选择"
                  disabled
                >
                  <el-option
                    v-for="item in Marriage"
                    :key="item.Id"
                    :label="item.Dictionary_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="出生年月" prop="Employees_DateBirth">
                <el-date-picker
                  v-model="ruleForms.Employees_DateBirth"
                  type="date"
                  placeholder="选择日期"
                  readonly="readonly"
                >
                </el-date-picker>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="邮箱" prop="Employees_Email">
                <el-input
                  v-model="ruleForms.Employees_Email"
                  placeholder="请输入内容"
                  readonly="readonly"
                ></el-input>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="身份证" prop="Employees_IdCard">
                <el-input
                  v-model="ruleForms.Employees_IdCard"
                  placeholder="请输入内容"
                  readonly="readonly"
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="部门" prop="Department_Id">
                <el-select
                  v-model="ruleForms.Department_Id"
                  placeholder="请选择"
                  disabled
                >
                  <el-option
                    v-for="item in Department"
                    :key="item.Id"
                    :label="item.Department_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <el-form-item label="职位" prop="Position_Id">
                <el-select v-model="ruleForms.Position_Id" placeholder="请选择" disabled>
                  <el-option
                    v-for="item in Position"
                    :key="item.Id"
                    :label="item.Position_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item label="员工类别" prop="Employees_Category">
                <el-select
                  v-model="ruleForms.Employees_Category"
                  placeholder="请选择"
                  disabled
                >
                  <el-option
                    v-for="item in Category"
                    :key="item.Id"
                    :label="item.Dictionary_Name"
                    :value="item.Id"
                  >
                  </el-option>
                </el-select>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"><div></div></el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisibless = false">取 消</el-button>
        <el-button type="primary" @click="submitForms('ruleForms')"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    var checkPhone = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("手机号不能为空"));
      } else {
        const reg = /^[1]([3-9])[0-9]{9}$/;
        console.log(reg.test(value));
        if (reg.test(value)) {
          callback();
        } else {
          return callback(new Error("请输入正确的手机号"));
        }
      }
    };
    return {
      tableData: [],
      name: "",
      department: "",
      position: "",
      phone: "",
      category: "",
      pageindex: 1,
      pagesize: 5,
      totalcount: 0,
      EducationBackground: [],
      Marriage: [],
      Category: [],
      Department: [],
      Position: [],
      ids: [],
      multipleSelection: [],
      ruleForm: {},
      ruleForms: {},
      formLabelWidth: "120px",
      dialogFormVisible: false,
      dialogFormVisibles: false,
      dialogFormVisibless:false,
      rules: {
        Employees_Name: [
          { required: true, message: "请输入姓名", trigger: "blur" },
        ],
        Employees_Phone: [
          { required: true, message: "请输入手机号", trigger: "blur" },
          { validator: checkPhone, trigger: "blur" },
        ],
        Employees_Universities: [
          { required: true, message: "请输入院校", trigger: "blur" },
        ],
        Employees_Professional: [
          { required: true, message: "请输入专业", trigger: "blur" },
        ],
        Employees_Address: [
          { required: true, message: "请输入家庭住址", trigger: "blur" },
        ],
        Employees_EducationBackground: [
          { required: true, message: "请选择学历", trigger: "change" },
        ],
        Employees_Email: [
          { required: true, message: "请输入邮箱", trigger: "change" },
          {
            type: "email",
            message: "请输入正确的邮箱地址",
            trigger: ["blur", "change"],
          },
        ],
      },
    };
  },
  methods: {
    GetShow() {
      this.$axios
        .get(
          "https://localhost:44360/api/app/t-mS_Employees-sevice/employees?name=" +
            this.name +
            "&department=" +
            this.department +
            "&position=" +
            this.position +
            "&phone=" +
            this.phone +
            "&category=" +
            this.category +
            "&pageindex=" +
            this.pageindex +
            "&pagesize=" +
            this.pagesize
        )
        .then((res) => {
          this.tableData = res.data.PageData;
          this.totalcount = res.data.PageTotal;
        });
    },
    //学历
    GetEducationBackground() {
      this.$axios
        .get(
          "https://localhost:44360/api/app/t-mS_Employees-sevice/education-background"
        )
        .then((res) => {
          this.EducationBackground = res.data;
        });
    },
    //婚姻
    GetMarriage() {
      this.$axios
        .get("https://localhost:44360/api/app/t-mS_Employees-sevice/marriage")
        .then((res) => {
          this.Marriage = res.data;
        });
    },
    //员工类别
    GetCategory() {
      this.$axios
        .get("https://localhost:44360/api/app/t-mS_Employees-sevice/category")
        .then((res) => {
          this.Category = res.data;
        });
    },
    //部门
    GetDepartment() {
      this.$axios
        .get("https://localhost:44360/api/app/t-mS_Employees-sevice/department")
        .then((res) => {
          this.Department = res.data;
        });
    },
    //职位
    GetPosition() {
      this.$axios
        .get("https://localhost:44360/api/app/t-mS_Employees-sevice/position")
        .then((res) => {
          this.Position = res.data;
        });
    },
    handleSizeChange(val) {
      this.pagesize = val;
      this.GetShow();
    },
    handleCurrentChange(val) {
      this.pageindex = val;
      this.GetShow();
    },
    handleDelete(row) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$axios
            .delete(
              "https://localhost:44360/api/app/t-mS_Employees-sevice/" +
                row.Id.toString() +
                "/employees"
            )
            .then((res) => {
              if (res.data > 0) {
                alert("删除成功");
                this.GetShow();
              } else {
                alert("删除失败");
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
      this.multipleSelection.forEach((item) => {
        this.ids.push(item.Id);
      });
    },
    DelEmployees() {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$axios
            .delete(
              "https://localhost:44360/api/app/t-mS_Employees-sevice/" +
                this.ids.toString() +
                "/employees"
            )
            .then((res) => {
              if (res.data > 0) {
                alert("删除成功");
                this.GetShow();
              } else {
                alert("删除失败");
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$axios
            .post(
              "https://localhost:44360/api/app/t-mS_Employees-sevice/employees",
              this.ruleForm
            )
            .then((res) => {
              if (res.data > 0) {
                alert("添加成功");
                this.dialogFormVisible = false;
                this.GetShow();
              } else {
                alert("添加失败");
              }
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    handleEdit(row) {
      this.ruleForms = row;
      this.dialogFormVisibles = true;
    },
    handleEdits(row) {
      this.ruleForms = row;
      this.dialogFormVisibless = true;
    },
    submitForms(formNames) {
      this.$refs[formNames].validate((valid) => {
        if (valid) {
          this.$axios
            .put(
              "https://localhost:44360/api/app/t-mS_Employees-sevice/employees",
              this.ruleForms
            )
            .then((res) => {
              if (res.data > 0) {
                alert("修改成功");
                this.dialogFormVisibles = false;
                this.GetShow();
              } else {
                alert("修改失败");
              }
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    Reset() {
      this.name = "";
      this.department = "";
      this.position = "";
      this.phone = "";
      this.category = "";
    },
  },
  created() {
    this.GetShow();
    this.GetEducationBackground();
    this.GetMarriage();
    this.GetCategory();
    this.GetDepartment();
    this.GetPosition();
  },
  computed: {},
};
</script>
<style scoped>
</style>
